﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

using ColladaDotNet.Pipeline.BSP.Quake3;

namespace Bsp2Dae
{
	class Program
	{
		static void Main(string[] args)
		{
			if (args.Length == 0)
			{
				foreach (var s in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.bsp"))
				{
					Convert(s, Path.ChangeExtension(s, ".dae"));
				}
			}
			else
			{
				foreach (var s in args)
				{
					Convert(s, Path.ChangeExtension(s, ".dae"));
				}
			}
		}

		static void Convert(string source, string dist)
		{
			Console.WriteLine("Converting "+source+" to "+dist);
			using (var s = File.OpenRead(source))
			{
				BSPReader r = new BSPReader();
				var file = r.Parse(s);

				var c = file.GetColladaFileSolidMesh();

				c.Save(dist);
			}
		}
	}
}
